#include <config.h>
#include <core.h>


msgd_global_t global;

int main(int argc ,char * argv[]){

  set_log_level(LOGL_DEBUG);


  if(argc >= 2){
    int log_fd = open(argv[1],O_WRONLY|O_APPEND|O_CREAT,FILE_MODE);
    if(log_fd < 0 )
      ERROR("log_fd error");
    INFO("log_fd :%d",log_fd);
    set_log_fd(log_fd); 
  }


  save_argv(argc,argv);

  FINE("init_setproctitle");
  init_setproctitle();

  set_proctitle((u_char*)"my msg proc");
  //FATAL("argc:%d argv:%p\n",argc,argv);


  if(init_global() == MSGD_ERROR)
    return MSGD_ERROR;

  if(msgd_init_process_environ() == MSGD_ERROR){
     ERROR("init process failed");
     return MSGD_ERROR;
  }

  msgd_start_worker_processes();

  FINE("main process goto pause()");
  pause();

#if ( __sparc__ || __sparc || __sparcv9 )
printf("( __sparc__ || __sparc || __sparcv9 )");
#endif

#if __amd64__
printf("__amd64__  \n");
#endif

#if __SUNPRO_C
  pause();
#endif
  return 0;
}
